#ifndef RW2_H
#define RW2_H

// Implements readers/writers problem 2:  writers may starve readers
//

#include "rwsync.h"

class ConditionalCriticalRegion;

class ReadersWritersProb2 : public ReadersWriters
{
	public:
		ReadersWritersProb2();
		~ReadersWritersProb2();

		bool8 initOk();

		bool8 beginRead();
		void endRead();

		bool8 beginWrite();
		void endWrite();

	protected:
		static bool8 noWriters(ReadersWritersProb2*);
		static bool8 okToWrite(ReadersWritersProb2*);

	protected:
		ConditionalCriticalRegion* ccr;
		uint32 nReaders, nWriters, busy;
};

#endif
